#ifndef _QY_HTTP_REQUEST_H
#define _QY_HTTP_REQUEST_H

#include <string>
#include <map>
#include "URI.h"


namespace qy
{

//Request = Request-Line
//			*((general-header
//			 | request-header
//			 | entity-header) CRLF)
//			CRLF
//			[message-body]

class HTTPRequest
{
public:
	HTTPRequest(const std::string &method, 
				const URI &requestURI, 
				const std::string &httpVersion = "1.1");
	virtual ~HTTPRequest();

	void setHeader(const std::string &name, const std::string &value);
	void setEntityBody(const char *data, size_t len);

	void getData(char **data, size_t *len);

private:
	//request-line = Method SP Request-URI SP HTTP-Version CRLF
	std::string requestLine();
	std::string header();

private:
	//request-line
	URI m_requestURI;
	std::string m_method;
	std::string m_httpVersion;

	//general header, request header, entity header
	std::map<std::string, std::string> m_header;

	//message body
	//message-body = entityBody 
	//				 | <entity-body encoded as per Transfer-Encoding
	//Transfer-Encoding, such as "chunked", "identity", "gzip", etc. is used to indicate an encoding transformation for the message.
	//Content-Coding, such as "chunked", "identity", "gzip", etc. indicates an encoding transformation that has been or can be applied to an entity.
	char *m_entityBody;
	size_t m_contentLength;
};

}
#endif
